﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.Diagnostics;

namespace XNADota.GamePlay.Ability
{
    public class MerchantAbilityObject : BasicObject
    {
        public const int MaxGoodCount = 12;

        public ItemObject[] Goods;

        public ControlPanel _ControlPanel;

        public void CreateMerchant(string Id)
        {
            ObjectsManager manager = GameplayWorld.Instance.ObjectsManager;

            string itemString = manager.GetFiledValue(EObjectType.UnitData, Id, "Sellitems");
            string[] itemsString = itemString.Split(new char[] { ',' });

            Goods = new ItemObject[itemsString.Length];
            for (int i = 0; i < itemsString.Length; i++)
            {
                Goods[i] = new ItemObject(itemsString[i]);
            }
        }

        public void ApplyControlPanel(ControlPanel controlPanel)
        {
            // update the control panel

            for (int i = 0; i < Goods.Length; i++)
                Goods[i].ApplyControlPanel(controlPanel, i);
        }

        public void Update(GameTime gameTime)
        {
        }

        public MerchantAbilityObject(string Id) : base(Id, EObjectType.AbilityData)
        {
        }
    }
}
